#!/usr/bin/php
<?php
/**
 * Apricot cli script 
 *
 * @package Apricot
 */

/** Require bootstrap */
require 'app/bootstrap.php';

$config = new Apricot_Config('app/config/config.ini');

// Mark as in a terminal
$config->output = 'term';
$appRoot = realpath(dirname(__FILE__));
$config->app_root = $appRoot;

// Setup and initialize ArgV object
require_once 'Qi/Console/ArgV.php';
$args = new Qi_Console_ArgV(
    $argv,
    array(
        'arg:action' => 'index',
        'arg:params' => '',
    )
);

$controllerAction = array(
    'controller' => $config->get('cli_controller'),
    'action'     => $args->action,
    'params'     => $args->params,
);

$_KERNEL = new Apricot_Kernel($config);

$request = new Apricot_Request($controllerAction + $_GET, $config);

Apricot_ExceptionHandler::initHandlers($_KERNEL);

$_KERNEL->dispatch($request);
